﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using University.Workshop.Model;
using University.Workshop.DataAccess;

namespace University.Workshop.Business
{
    public static class ProductUnsubscribeManager
    {


        public static Product UnsubscribeProduct(long id)
        {
            Product product = ProductDataAccess.GetProductById(id);
            try
            {                
                if (product.Status == "OnAuction")
                {
                    throw new ValidationException(product.Name + " is on auction so can't be unsubscribed");
                }
                
            }
            catch (Exception)
            {
                throw new ValidationException(product.Name + " is on auction so can't be unsubscribed");
            }
            product = ProductDataAccess.Unsubscribe(product);
            return product;
        }
    }
}
